<!--
 * Description: SupplyCloud新增页面
 * Company: 联宝（合肥）电子科技有限公司
 * Author: Dongxu.Ni
 * Date: 2020/04/14 02:52
-->

<template>
  <div>
    <!--数据表单-->
    <el-form label-width="150px" :model="formData" size="mini">
      <el-row>
        <!-- pn -->
        <el-col :span="12">
          <el-form-item label="PN">
            <el-input v-model="formData.pn" clearable />
          </el-form-item>
        </el-col>

        <!-- pnGroup -->
        <el-col :span="12">
          <el-form-item label="PNGroup">
            <el-input v-model="formData.pnGroup" clearable />
          </el-form-item>
        </el-col>

        <!-- plant -->
        <el-col :span="12">
          <el-form-item label="Plant">
            <el-input v-model="formData.plant" clearable />
          </el-form-item>
        </el-col>

        <!-- price -->
        <el-col :span="12">
          <el-form-item label="Price">
            <el-input-number
              v-model="formData.price"
              clearable
              controls-position="right"
              :min="1"
            />
          </el-form-item>
        </el-col>

        <!-- sourceCode -->
        <el-col :span="12">
          <el-form-item label="SourceCode">
            <el-input v-model="formData.sourceCode" clearable />
          </el-form-item>
        </el-col>

        <!-- sourcingType -->
        <el-col :span="12">
          <el-form-item label="SourcingType">
            <el-input v-model="formData.sourcingType" clearable />
          </el-form-item>
        </el-col>

        <!-- tower -->
        <el-col :span="12">
          <el-form-item label="Tower">
            <el-input v-model="formData.tower" clearable />
          </el-form-item>
        </el-col>

        <!-- gr -->
        <el-col :span="12">
          <el-form-item label="GR">
            <el-input-number v-model="formData.gr" clearable controls-position="right" :min="1" />
          </el-form-item>
        </el-col>

        <!--group-->
        <el-col :span="12">
          <el-form-item label="Group">
            <el-input v-model="formData.group" clearable />
          </el-form-item>
        </el-col>

        <!-- vendorCode -->
        <el-col :span="12">
          <el-form-item label="VendorCode">
            <el-input v-model="formData.vendorCode" clearable />
          </el-form-item>
        </el-col>

        <!-- vendorName -->
        <el-col :span="12">
          <el-form-item label="VendorName">
            <el-input v-model="formData.vendorName" clearable />
          </el-form-item>
        </el-col>

        <!-- vendorSimpleName -->
        <el-col :span="12">
          <el-form-item label="VendorSimpleName">
            <el-input v-model="formData.vendorSimpleName" clearable />
          </el-form-item>
        </el-col>

        <!-- city -->
        <el-col :span="12">
          <el-form-item label="City">
            <el-input v-model="formData.city" clearable />
          </el-form-item>
        </el-col>

        <!--country-->
        <el-col :span="12">
          <el-form-item label="Country">
            <el-input v-model="formData.country" clearable />
          </el-form-item>
        </el-col>

        <!-- lastFactory -->
        <el-col :span="12">
          <el-form-item label="LastFactory">
            <el-input v-model="formData.lastFactory" clearable />
          </el-form-item>
        </el-col>

        <!-- location -->
        <el-col :span="12">
          <el-form-item label="Location">
            <el-input v-model="formData.location" clearable />
          </el-form-item>
        </el-col>

        <!-- date -->
        <el-col :span="12">
          <el-form-item label="Date">
            <el-date-picker
              v-model="formData.date"
              :picker-options="pickerOptions"
              type="date"
              value-format="yyyy-MM-dd"
            />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <span style="display: block;text-align: center;margin-top: 5px">
      <!--取消按钮-->
      <el-button size="medium" @click="cancel">{{ $t('button.cancel') }}</el-button>
      <!--保存按钮-->
      <el-button size="medium" type="primary" @click="save">{{ $t('button.save') }}</el-button>
    </span>
  </div>
</template>

<script>
import { sapGRAdd } from '@/api/spendingSaving/spendingSaving'

export default {
  name: 'SapAdd',
  props: {},
  data() {
    return {
      formData: {},
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() < Date.now()
        }
      }
    }
  },

  methods: {
    save() {
      sapGRAdd(this.formData).then(() => {
        this.$emit('save')
      })
    },
    cancel() {
      this.$emit('cancel')
    }
  }
}
</script>
